<template>

	<view class="content">
		<navbar></navbar>
		<view class="title"></view>
		
		<view class="body" v-if="dataType == 'all' && list.length != 0">
			<view class="item-warp" v-for="(item,index) in list" :key="index">
				<view class="item">
					<view class="img">
						<img :src="item.img_url" alt="">
					</view>
					<view class="text">
						<view class="text-item">
							<view class="text-item-title">{{item.name}}</view>
							<!-- <view v-if="item.l_sku_type == 2 && item.is_send == 0 && item.order_address == ''">待兑换</view>
							<view v-else-if="item.l_sku_type == 2 && item.order_address != '' && item.express.express_company == ''">待发货</view>
							<view v-else-if="item.l_sku_type == 2 && item.express.express_company != ''">已发货</view>
							<view v-else-if="item.l_sku_type == 3">已发货</view>
							<view v-else-if="item.l_sku_type == 1 && item.is_send == 0">待发货</view>
							<view v-else-if="item.l_sku_type == 1 && item.is_send == 1">已发货</view>
							<view v-else-if="item.l_sku_type == 4 && item.is_send == 0">待发货</view>
							<view v-else-if="item.l_sku_type == 4 && item.is_send == 1">已发货</view> -->
						</view>
						<view class="text-item" style="width: 300rpx;height: 40rpx;overflow: hidden;">
							{{item.sku_name}}
						</view>
						<view class="text-item">
							<view >{{item.time}}</view>
							<view class="rightTop" v-if="item.is_address == 1" @click="nav_purchase(item.order_id)">兑换</view>
							<view class="rightTop" v-if="item.express.express_company != ''" @click="seeLogistics(item.express)">物流</view>
						</view>
					</view>
					<!-- <view  v-if="item.type">{{item.type}}</view> -->
				</view>
				<view class="rightBottom" v-if="item.order_address">{{item.order_address}}</view>
			</view>
		</view>
		<view class="yoshop-notcont" v-else style="position: fixed; top:50%;left: 50%;transform: translate(-50%,-50%);white-space: nowrap">
			<!-- <text class="dy-iconfont icon-empty"></text> -->
			<text class="iconfont icon-wushuju"></text>
			<text class="cont">快去抽奖吧，您还没有奖品哦~</text>
		</view>
		<view class="zz" v-show="isPwd">
			<view class="popup">
				<view class="title">
					物流信息
				</view>
				<view class="">
					物流公司:{{express_company}}
				</view>
				<view class="">
					快递号:{{express_no}}
				</view>
				<view class="btn" style="border-top:1rpx solid #dfdfdf;height: 100rpx;text-align: center;line-height: 100rpx;">
					<view @click="isPwd = false" style="width: 295rpx;height: 100%;border-right: 1rpx solid #dfdfdf;">取消</view>
					<view @click="isCopy()" style="width: 300rpx;height: 100%;">复制单号</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {//l_sku_type  1--虚拟  2--实物  3--能量  4--藏品
			//is_send  0--未发货  1--发货
			//is_address  0--不填  1--填
				dataType: 'all', // 列表类型
				list:[],
				page:1,
				last_page:1,//总页数
				hasMore:true,
				isPwd:false,
				express_company:'',
				express_no:'',
				l_id:0,
			}
		},
		mounted() {

		},
		onLoad(options) {
			console.log("11111")
			this.l_id = options.l_id
			 this.getBankList()
		},
		onShow() {
			console.log('onshow')
			this.list = []
			this.page = 1
			this.getBankList()
		},
		//触底加载
		onReachBottom() {
			console.log('触底')
			// 已经是最后一页
			if (this.page >= this.last_page) {
				app.showToast('已经到底了哦~');
			}else{
				this.page = ++this.page
				this.getBankList(true);
			} // 加载下一页列表
			console.log(this.page)
			
		},
		//下拉刷新
		onPullDownRefresh(e) {
			this.list = []
			this.page = 1
			this.getBankList();
		},
		methods: {
			//查看物流信息
			seeLogistics(e){
				this.isPwd = true
				this.express_company = e.express_company
				this.express_no = e.express_no
			},
			//复制
			isCopy(){
				uni.setClipboardData({
				    data: this.express_no, // e是你要保存的内容
				    success: function () {
						uni.showToast({
							title:'复制成功',
							icon:'none'
						})
				    }
				})
			},
			getBankList() {
				let _this = this
				app._post_form('Jadegoods/getJadeLuckyOrderList', {
					l_id: _this.l_id,
					page:_this.page
				}, function(result) {
					
					if (1 == result.code) {
						_this.last_page = result.data.list.last_page
						let a = result.data.list
						console.log(a.data)
						a.data.forEach((item) => {
							_this.list.push(item)
						})
						_this.$forceUpdate()
					}
				}, null, function() {
					uni.stopPullDownRefresh();
				});
			},
			nav_purchase(e) {
				uni.navigateTo({
					url: `./newPurchase?order_id=${e}`
				});
			},
			//跳转转盘
			nva_Rounturn(){
				uni.navigateTo({
					url:'./roundTurntable'
				})
			}
		}

	}
</script>


<style scoped lang="scss">
	page {
		// background-color: #080808;
	}
	.content{
	}
	.title {
		width: 100%;
		height: 30rpx;
		background: url(@/static/images/orderTitle.png);
		background-size: 100% 100%;
		position: fixed;
		top: 0;
		z-index: 4;
	}



	.body {
		padding: 32rpx;
		color: #000;
		font-size: 28rpx;
		.item-warp{
			background-color: #fff;
			border-radius: 8rpx;
		}
		.rightBottom{
			height: 85rpx;
			display: flex;
			align-items: center;
			
			font-size: 26rpx;
			color: #000;
			margin: 0 32rpx;
			
			border-top: 1px solid #292C2D;
			
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}
		.item {
			display: flex;
			margin-top:32rpx;
			padding: 30rpx;
			color: #000;
			.img {
				width: 160rpx;
				height: 160rpx;
				img {
					width: 100%;
					height: 100%;
					object-fit: cover!important;
					border-radius: 8rpx;
				}
			}
			.text{
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				width: 100%;
				.text-item{
					
					font-size: 26rpx;
					color: #000;
					display: flex;
					justify-content: space-between;
					.text-item-title{
						width: 300rpx;
						height: 40rpx;
						overflow: hidden;
						font-size: 28rpx;
						color: #000;
					}
				}
				.button{
					color: #D6B05A;
					width: 100rpx;
					height: 40rpx;
					font-size: 26rpx;
					text-align: center;
					line-height: 40rpx;
					background: rgba(214,176,90,0.12);
					border: 1px solid #D6B05A;
				}
			}
			
			.rightTop{
				font-size: 26rpx;
				// background-color: #D8B255;
				text-align: center;
				line-height: 40rpx;
				width: 100rpx;
				height: 40rpx;
				border-radius: 4rpx;
				background:rgba(216,178,85,0.12);
				
				color: #D6B05A;
			}
			
			
		}
		
	}
	.zz{
		  position: fixed;
		  top: 0;
		  left: 0;
		  right: 0;
		  bottom: 0;
		  z-index: 14;
		  background: rgba(0, 0, 0, 0.5);
		  display: flex;
		  justify-content: space-around;
		  align-items: center;
		  z-index: 3;
		  .popup{
			  padding: 30rpx;
			  padding-bottom: 0;
			  border-radius: 20rpx;
			  width: 600rpx;
			  height: 300rpx;
			  background-color: #fff;
			  display: flex;
			  flex-direction: column;
			  justify-content: space-between;
			  .title{
				  margin-top: 20rpx;
				  text-align: left;
				  height: 80rpx;
				  line-height: 80rpx;
				  font-weight: 700;
				  // border-bottom: 1rpx solid #999;
			  }
			  .btn{
				  display: flex;
			  }
		  }
	}
</style>
